/**
 * 
 */
package com.shy.portal.controller;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.shy.base.controller.AbsController;
import com.shy.base.vo.AppConstants;
import com.shy.base.vo.EasyuiPagerVo;
import com.shy.base.vo.PagerFilter;
import com.shy.portal.entity.UserLog;
import com.shy.portal.service.UserLogService;

/**
 * <p>Title:UserLogController </p>
 * <p>Description: 系统操作日志 controller层</p>
 * <p>Company:ipebg </p> 
 * @author H2013788
 * @date 2019年07月12日
 */
@Controller
@RequestMapping("log")
public class UserLogController extends AbsController {
	
	/**
	 * service层
	 */
    @Resource
    private UserLogService logService;

	/**
	 * 加载页面
	 * @return
	 * @author H2013788
	 * @date 2019年07月12日
	 */
	@RequestMapping("page")
	public String loadPage() {
		return "portal/user_log_list";
	}
	
	/**
	 * 加载数据
	 * 
	 * @author H2013788
	 * @date 2019年07月12日
	 */
	@RequestMapping("data")
	public void loadData(UserLog log, Integer page, Integer rows, HttpServletResponse response) {
		PagerFilter pagerFilter = getPageable(rows == null ? 15L : rows);
        pagerFilter.setPagePer(null == page ? 1 : page);
        //默認按照创建时间的逆序排序
        LinkedHashMap<String, String> orderby = new LinkedHashMap<>();
        orderby.put("createTime", PagerFilter.DIRECTION_DESC);
        pagerFilter.setOrderby(orderby);
        
        String[] likes = { "userNo", "userName", "module", "url", "ip" };
        Map<String, String[]> filterMap = new HashMap<>();
        filterMap.put(AppConstants.LIKE_TYPES, likes);
        
        pagerFilter = logService.listByPager(log, filterMap, pagerFilter);
        //输出json
        writeResponse(new StringBuffer(gsonDateTime.toJson(new EasyuiPagerVo(pagerFilter))), response);
	}
	
}
